const path = require('path');
const { basename } = require('path');
class HomeCtl{
    index(ctx){
        ctx.body = `<h1>主页</h1>`
    }
    upload(ctx){
        const file = ctx.request.files.file;
        //获取上传文件的baseName,即文件名+后缀名(不包括路径);
        const baseName = path.basename(file.path);
        //将文件名与域名和路径拼凑起来返回到客户端;
        ctx.body = `${ctx.origin}/uploads/${baseName}`;
    }
}

module.exports = new HomeCtl();